package com.cat.chapter042;

/**
 * @author cat
 * @description A,B吃草
 * @create 2025/7/11 08:50
 * @since JDK17
 */

public class Solution02 {
    public String f(int rest, String cur, String enemy) {
        if (rest < 5) {
            return rest == 0 || rest == 2 ? enemy : cur;
        }
        int i = 1;  // 这次你要吃多少份草
        while (i <= rest) {
            if (f(rest - i, enemy, cur).equals(cur)) {
                return cur;
            }
            i *= 4;
        }
        return enemy;
    }
    public String g(int rest, String cur, String enemy) {
        if (rest % 5 == 0 || rest % 5 == 2) {
            return enemy;
        } else {
            return cur;
        }
    }
    public static void main(String[] args) {
        Solution02 solution02 = new Solution02();
        for (int i = 0; i < 50; i++) {
            System.out.println(i + " : " + solution02.f(i, "A", "B"));
        }
    }
}
